﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XBD.MyBaseCode
{
    internal class TestValue
    {

        static void swap(ref int x, ref int y) 
        {
            int temp;
            temp = x;
            x = y;
            y = temp;
        }

        static void getBook(out int x) 
        {
            x = 5;
        }
        public static void getValue() 
        {
            int a = 100;
            int b = 500;

            swap(ref a, ref b);
            //Console.WriteLine("a:" + a);
            // Console.WriteLine("b:" + b);
            getBook(out a);

           
            Console.WriteLine("a:" + a);
            Console.ReadLine();

        }
       
        public static void Init() 
        
        {

            string joined = string.Join("-", new[] { "a", "b", "c" }); // "a-b-c"
            Console.WriteLine($"数值：{joined}");

            //Func<int, string> getNumberDescription = num => {
            //    if (num > 0)
            //        return $"{num} 是正数";
            //    else if (num < 0)
            //        return $"{num} 是负数";
            //    else
            //        return "数字是 0";
            //};

            //getNumberDescription(5);

            // 委托类型（定义函数签名）
            Func<int, int,int, int> add = (a,b,c) => a + b + c;
            int result = add(3, 4,5); // 调用 Lambda 表达式（类似调用函数）
            Console.WriteLine($"数值：{result}");

            //Console.WriteLine(getNumberDescription(5));  // 输出：5 是正数
            // Console.WriteLine(getNumberDescription(-3)); // 输出：-3 是负数


            /*List<int> numbers = new List<int> { 10, 20, 30, 40 };

            // 遍历整数列表
            foreach (int num in numbers)
            {
                Console.WriteLine($"数值：{num}");
            }

            string[] fruits = { "苹果", "香蕉", "橙子" };

            // 遍历字符串数组
            foreach (string fruit in fruits)
            {
                Console.WriteLine(fruit);
            }

            String[] anotherArray = new String[] { "0", "banana", "cherry" };


            string temp;
            temp = anotherArray[2];

            Console.WriteLine(temp);*/

        }
    }
}
